import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../components/login.vue'
import Home from '../components/home.vue'
import Welcome from '../components/welcome.vue'
import Users from '../components/user/Users.vue'
import Rights from '../components/power/Rights.vue'
import Roles from '../components/power/Roles.vue'
import Cate from '../components/goods/Cate.vue'
import Params from '../components/goods/params.vue'
import GoodList from '../components/goods/List.vue'
import AddGoods from '../components/goods/Add.vue'
import Order from '../components/order/Order.vue'
import Report from '../components/report/Report.vue'

const originalPush = VueRouter.prototype.push
   VueRouter.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter)

const router = new VueRouter ({
  mode:"history",
  routes:[
    {path:'/',redirect:'/login'},
    {path:'/login',component: Login},
    {path:'/welcome',component: Welcome},
    {path:'/home',component: Home,
    children:[
      {path:'/users',component: Users},
      {path:'/rights',component:Rights},
      {path:'/roles',component:Roles},
      {path:'/categories',component:Cate},
      {path:'/params',component:Params},
      {path:'/goods',component:GoodList},
      {path:'/goods/add',component:AddGoods},
      {path:'/orders',component:Order},
      {path:'/reports',component:Report}
      ]
    }
  ],
})

export default router
